﻿  <?php include("conn.php");
include("../tool/UpFileTool.class.php");
require('../tool/UploadImage.class.php');
mysql_query('SET NAMES UTF8'); 
error_reporting(0);
	  

class MyPrizeBean
{

	public $result;

	function __construct($result)
	{
		
		$this->result = $result;
	}
}
	$smallImg = '';
	$images = '';
	$upload = new Upload("file");
	$date = date('Y-m-d');
	$sumbimage = '../sumbimage/'.$date;
	$srcimage = '../srcimage/'.$date;
	$upload->setFilePath($srcimage);
	$upload->setSmallFilePath($sumbimage);
	$re = $upload->upload();
	if($re){
		$path = $upload->getPath();
		$smallPath = $upload->getSmallimg();
		
		foreach ($path as $key => $value) {
			$path[$key] = 'srcimage/'.$date.'/'.$value;
			$smallPath[$key] = 'sumbimage/'.$date.'/'.$smallPath[$key];
		}
	
		$images = implode(',',$path);
		$smallImg = implode(',',$smallPath);
	}

	$prize = array();
 if($_REQUEST[userid]!="")
 {         

$date=date("Y-m-d H:i:s");
	$str = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $_REQUEST['content']);//转义表情 （输入法表情输入时使用）
	$zhuan=addslashes($str);//转义
	$str = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $_REQUEST['title']);//转义表情 （输入法表情输入时使用）
	$title=addslashes($str);//转义
	
$srat=mysql_query("INSERT INTO talks(userid,addtime,content,role,path,images,thumbImages,title,cityid) VALUES ('$_REQUEST[userid]','$date','$zhuan','$_REQUEST[role]','$_REQUEST[path]','$images','$smallImg','$title','$_REQUEST[city]')");


	

	      if($srat==true)
	     {
		  $der=100;
		  
		  }
	
		}
		 else
		  {
		   $der=300;
		  }

$prize[] = new MyPrizeBean($der);
echo json_encode($prize);

?>